<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/layout/template.xhtml">

    <f:metadata>
        <f:viewParam name="sysCodeId" value="#{sysCodeEdit.sysCodeId}"/>
        <f:viewParam name="codeType" value="#{sysCodeEdit.sysCode.codeType}"/>
        <f:event type="javax.faces.event.PreRenderViewEvent" listener="#{sysCodeEdit.beginConversation}"/>
    </f:metadata>

    <ui:define name="content">
        <h:form id="sysCodeEditForm">
            <p:panel>
                <f:facet name="header">
                    <h:outputText class="ui-icon ui-icon-gear" style="display: inline-block"/>
                    <h:outputText value="添加/修改系统代码信息"/>
                </f:facet>

                <h:panelGrid columns="2" columnClasses="grid-title, grid-normal">
                    <h:outputText value="系统代码ID："/>
                    <h:outputText value="#{sysCodeEdit.sysCode.sysCodeId}"/>

                    <p:outputLabel for="codeType" value="代码类型："/>
                    <p:selectOneMenu id="codeType"
                                     value="#{sysCodeEdit.sysCode.codeType}"
                                     required="true"
                                     requiredMessage="必须输入代码类型">
                        <f:selectItems value="#{appResource.getSysCodeList('代码类型')}"
                                       var="v_sysCode"
                                       itemValue="#{v_sysCode.codeValue}"
                                       itemLabel="#{v_sysCode.codeName}"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="codeName" value="代码名称："/>
                    <p:inputText id="codeName"
                                 value="#{sysCodeEdit.sysCode.codeName}"
                                 size="20"
                                 required="true"
                                 requiredMessage="必须输入代码名称"/>

                    <p:outputLabel for="codeValue" value="代码值："/>
                    <p:inputText id="codeValue"
                                 value="#{sysCodeEdit.sysCode.codeValue}"
                                 size="50"
                                 required="true"
                                 requiredMessage="必须输入代码值"/>

                    <p:outputLabel for="enabled" value="是否启用："/>
                    <p:selectOneRadio id="enabled"
                                   value="#{sysCodeEdit.sysCode.enabled}">
                        <f:selectItem itemValue="#{true}" itemLabel="启用"/>
                        <f:selectItem itemValue="#{false}" itemLabel="禁用"/>
                    </p:selectOneRadio>

                    <p:outputLabel for="orderNo" value="排序序号："/>
                    <p:spinner id="orderNo"
                               value="#{sysCodeEdit.sysCode.orderNo}"
                               min="1"
                               max="999"
                               size="3"
                               required="true"
                               requiredMessage="必须输入排序序号"/>

                    <p:outputLabel for="remark" value="备注："/>
                    <h:panelGroup>
                        <p:inputTextarea id="remark"
                                         value="#{sysCodeEdit.sysCode.remark}"
                                         rows="5"
                                         cols="40"
                                         maxlength="500"
                                         counter="remarkCounter"
                                         counterTemplate="还可输入{0}个字符"
                                         autoResize="false"/>
                        <p:tooltip id="remarkCounter"
                                   for="remark"
                                   showEffect="slide"
                                   hideEffect="slide"
                                   trackMouse="true"/>
                    </h:panelGroup>

                    <h:outputText value="创建时间："/>
                    <h:outputText value="#{sysCodeEdit.sysCode.createTime}">
                        <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/>
                    </h:outputText>

                    <h:outputText value="更新时间："/>
                    <h:outputText value="#{sysCodeEdit.sysCode.updateTime}">
                        <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/>
                    </h:outputText>

                    <h:outputText value="版本："/>
                    <h:outputText value="#{sysCodeEdit.sysCode.version}"/>
                </h:panelGrid>

                <f:facet name="footer">
                    <h:panelGrid columns="2">
                        <p:commandButton value="确定"
                                         action="#{sysCodeEdit.save}"
                                         icon="ui-icon-check"/>
                        <p:commandButton value="取消"
                                         action="#{sysCodeEdit.cancel}"
                                         icon="ui-icon-close"
                                         immediate="true"/>
                    </h:panelGrid>
                </f:facet>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>
